package com.yima.baseproj.module.app.picture;

import com.yima.baseproj.aop.log.Logging;
import com.yima.baseproj.module.config.utils.ResultUtil;
import com.yima.baseproj.module.config.utils.ResultVo;
import com.yima.baseproj.module.sys.picture.PictureEntity;
import com.yima.baseproj.module.sys.picture.PictureService;
import com.yima.baseproj.module.sys.picture.model.PictureAddModel;
import com.yima.baseproj.module.sys.student.model.StudentSelectModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/api/app/picture")
@RestController
public class AppPictureController {

    @Autowired
    private PictureService pictureService;

    @ApiOperation("根据学生id 查询照片列表")
    @GetMapping("/findByStudentId/{studentId}")
    public ResultVo findAllByClassId(@PathVariable int studentId) {
        List<PictureEntity> pictureList = pictureService.findByStudentId(studentId);
        return ResultUtil.success(pictureList);
    }




    @Logging(tags = "相册管理",value = "添加")
    @ApiOperation("添加")
    @PostMapping("/add")
    public void save(@RequestBody @Validated PictureAddModel picture) {
        pictureService.add(picture,1);
    }
}

